/*	FileDescriptor.java
 *
 *	Copyright (c) Manateem Challenge Project, Zaia Group, and contributors 2010
 *
 *	This file is part of MSGToolSuite ('this project').
 *
 *	This project is free software: you can redistribute it and/or modify it
 *	under the terms of the GNU General Public License as published by the Free
 *	Software Foundation, either version 3 of the License, or (at your option)
 *	any later version.
 *
 *	This project is distributed in the hope that it will be useful, but WITHOUT
 *	ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 *	FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 *	more details.
 *
 *	You should have received a copy of the GNU General Public License along with
 *	this project. If not, see <http://www.gnu.org/licenses/>.
 */
package edu.bu.manateem.msg.analysis;

import java.io.Serializable;

//Imports
//import java.math.BigInteger;
//import java.util.Random;

/**
 *	<p>
 *	A descriptor object for filesystem files.
 *	</p>
 *	<p>
 *	Descriptor objects are n-tuple groupings of attributed properties of their
 *	respective described objects, deserving of their own class for code clarity
 *	and de-coupling, but undeserving of rigorous definition as a normal object.
 *	</p>
 *
 *
 *	@author
 *		Christopher Jacobs
 *
 *	@version
 *		1.0
 *
 *	@changelog
 *		Apr 19, 2010	- Version 1.0.
 */
public class FileDescriptor
	implements Serializable
{
	/*
	 * TYPES
	 */

	/*
	 * CONSTANTS
	 */

	//
	private static final long serialVersionUID = 1L;
	
	/*
	 * FIELDS
	 */

	public String fileName;
	public String filePath;
	public String fileType;
	
	/*
	 * CONSTRUCTORS
	 */

	public FileDescriptor()
	{
		fileName = "";
		filePath = "";
		fileType = "";
	}
	
	public FileDescriptor(String name,String path,String type)
	{
		fileName = name;
		filePath = path;
		fileType = type;
	}
	
	/*
	 * INITIALIZERS
	 */

	/*
	 * METHODS
	 */

	/**
	 *	<p>
	 *	Indicates whether some other object is "equal to" this one.
	 *	</p>
	 *
	 *	@see
	 *		java.lang.Object#equals(java.lang.Object)
	 *
	 *	@since
	 *		1.0
	 */
	@Override
	public boolean equals(Object obj)
	{
		if (obj == this)
		{
			return true;
		}
		if ((obj == null) || !(obj instanceof FileDescriptor))
		{
			return false;
		}
		
		FileDescriptor other = (FileDescriptor) obj;
		return ((fileName != null) && (fileName.equals(other.fileName)))
			&& ((filePath != null) && (filePath.equals(other.filePath)))
			&& ((fileType != null) && (fileType.equals(other.fileType)));
	}
	
	/**
	 *	<p>
	 *	Returns a hash code value for the object.
	 *	</p>
	 *
	 *	@see
	 *		java.lang.Object#hashCode()
	 *
	 *	@since
	 *		1.0
	 */
	@Override
	public int hashCode()
	{
		// final int prime =
		// BigInteger.probablePrime(8,new
		// Random(System.currentTimeMillis())).intValue();
		final int prime = 31;
		
		int hash = prime + ((fileName == null)
			? 0
			: fileName.hashCode());
		hash = hash * prime + ((filePath == null)
			? 0
			: filePath.hashCode());
		hash = hash * prime + ((fileType == null)
			? 0
			: fileType.hashCode());
		
		return hash;
	}
	
}
